package com.youyou.fusheng2.Person;

import com.youyou.fusheng2.Moudle.FuShengCallBack;
import com.youyou.fusheng2.Utils.OkHttp;

import java.net.ConnectException;

import okhttp3.Response;

/**
 * @name fusheng2
 * @class name：com.youyou.fusheng2.Person
 * @anthor 浮生 QQ:2567294605
 * @time 2020/8/17 20:12
 * @to
 */

public class FuShengMoudle {

    private FuShengCallBack fuShengCallBack;
    private OkHttp          okHttp;

    public FuShengMoudle(FuShengCallBack fuShengCallBack) {
        this.fuShengCallBack = fuShengCallBack;
        okHttp = new OkHttp();
    }

    public void getUrlDate(final String url, int flage) {
        try {
            Response execute = okHttp.getData(url).execute();
            String string = execute.body().string();
            fuShengCallBack.GetSuccess(string, flage);
        } catch (ConnectException e) {
            fuShengCallBack.GetError("服务器异常/网络异常", 100);
        } catch (Exception e) {
            e.printStackTrace();
            fuShengCallBack.GetError(e.toString(), 100);
        }
    }
}
